let dataInfo = [{
        name: "安东尼 戴维斯",
        money: 892001
    },
    {
        name: "凯里 欧文",
        money: 668932
    },
    {
        name: "史蒂夫 库里",
        money: 698756
    },
    {
        name: "德里克 罗斯",
        money: 492489
    },
    {
        name: "保罗 乔治",
        money: 853957
    },
    {
        name: "勒布朗 詹姆斯",
        money: 968472
    },
    {
        name: "詹姆斯 哈登",
        money: 718225
    },
    {
        name: "凯文 杜兰特",
        money: 889147
    },
];
let body = document.querySelector("body")
let add_user = document.getElementById("add_user")
let double = document.getElementById("double")
let show_millionaire = document.getElementById("show_millionaire")
let sort = document.getElementById("sort")
let calculate = document.getElementById("calculate")
let main = document.getElementById("main")
let toggle = document.getElementById("toggle")
let nav = document.querySelector("nav")
index = 0;


//  console.log(add_user);
toggle.addEventListener("click", function() {
    if (!body.style.transform) {
        body.style.transform = "translate(200px)";
    } else {
        body.removeAttribute("style")

    }
})

//添加账户
add_user.addEventListener("click", function() {
    if (index < dataInfo.length) {
        let newDiv = document.createElement("div")
        newDiv.classList.add("bottom_box");
        // console.log(newDiv);
        newDiv.innerHTML = `<span>${dataInfo[index%8].name}</span><span>$${dataInfo[index%7].money}</span>`
        main.appendChild(newDiv);
        index++
        // console.log(newDiv);
    }

})

//资金翻倍
double.addEventListener("click", function() {
    let bottom_box = document.querySelectorAll(".bottom_box")
    bottom_box.forEach(function(item) {
        console.log(item.lastChild.innerText.slice(1) * 2);
        item.lastChild.innerText =
            `$${item.lastChild.innerText.slice(1) * 2}`
    })
})

//查询富翁
show_millionaire.addEventListener("click", function() {
    let bottom_box = document.querySelectorAll(".bottom_box")
    bottom_box.forEach(function(item) {
        if (item.lastChild.innerText.slice(1) > 1000000) {
            main.appendChild(item);
        } else {
            item.remove();
        }
    })

})

//财富榜



//计算总额